From: tsteven4 Date: Wed, 27 Feb 2019 15:33:48 +0000 (-0700) Subject: Merge branch 'master' into routelist X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~8^2~22^2~1 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=efbfbec5a24784d7973505b1936353389a4c154f;p=gpsbabel.git Merge branch 'master' into routelist including manual resolution of conflict in main.cc. --- efbfbec5a24784d7973505b1936353389a4c154f diff --cc main.cc index eb869e252,2ccf26e62..d19a6fd69 --- a/main.cc +++ b/main.cc @@@ -211,21 -227,11 +227,13 @@@ run(const char* prog_name const char* ovec_opts = nullptr; const char* fvec_opts = nullptr; int opt_version = 0; - int did_something = 0; - const char* prog_name = argv[0]; /* argv is modified during processing */ + bool did_something = false; - queue* wpt_head_bak, *rte_head_bak, *trk_head_bak; /* #ifdef UTF8_SUPPORT */ - signed int wpt_ct_bak, rte_ct_bak, trk_ct_bak; /* #ifdef UTF8_SUPPORT */ + queue* wpt_head_bak; /* #ifdef UTF8_SUPPORT */ + RouteList* rte_head_bak, *trk_head_bak; /* #ifdef UTF8_SUPPORT */ + signed int wpt_ct_bak; /* #ifdef UTF8_SUPPORT */ + bool lists_backedup; /* #ifdef UTF8_SUPPORT */ - QStack qargs_stack = QStack(); + QStack qargs_stack; - // Create a QCoreApplication object to handle application initialization. - // In addition to being useful for argument decoding, the creation of a - // QCoreApplication object gets Qt initialized, especially locale related - // QTextCodec stuff. - // For example, this will get the QTextCodec::codecForLocale set - // correctly. - QCoreApplication app(argc, argv); // Use QCoreApplication::arguments() to process the command line. QStringList qargs = QCoreApplication::arguments(); @@@ -715,9 -664,93 +661,93 @@@ fatal("Nothing to do! Use '%s -h' for command-line options.\n", prog_name); } + return 0; + } + + int + main(int argc, char* argv[]) + { + #ifdef AFL_INPUT_FUZZING + AFL_INIT_ARGV(); + #endif + int rc = 0; + const char* prog_name = argv[0]; /* may not match QCoreApplication::arguments().at(0)! */ + + // MIN_QT_VERSION in configure.ac should correspond to the QT_VERSION_CHECK arguments in main.cc and gui/main.cc + #if (QT_VERSION < QT_VERSION_CHECK(5, 9, 0)) + #error This version of Qt is not supported. + #endif + + #ifdef DEBUG_LOCALE + printf("Initial locale: %s\n",setlocale(LC_ALL, NULL)); + #endif + + // Create a QCoreApplication object to handle application initialization. + // In addition to being useful for argument decoding, the creation of a + // QCoreApplication object gets Qt initialized, especially locale related + // QTextCodec stuff. + // For example, this will get the QTextCodec::codecForLocale set + // correctly. + QCoreApplication app(argc, argv); + + // The first invocation of QTextCodec::codecForLocale() or + // construction of QCoreApplication object + // may result in LC_ALL being set to the native environment + // as opposed to the initial default "C" locale. + // This was demonstrated with Qt5 on Mac OS X. + #ifdef DEBUG_LOCALE + printf("Locale after initial setup: %s\n",setlocale(LC_ALL, NULL)); + #endif + // As recommended in QCoreApplication reset the locale to the default. + // Note the documentation says to set LC_NUMERIC, but QCoreApplicationPrivate::initLocale() + // actually sets LC_ALL. + // Perhaps we should restore LC_ALL instead of only LC_NUMERIC. + if (strcmp(setlocale(LC_NUMERIC,nullptr), "C") != 0) { + #ifdef DEBUG_LOCALE + printf("Resetting LC_NUMERIC\n"); + #endif + setlocale(LC_NUMERIC,"C"); + #ifdef DEBUG_LOCALE + printf("LC_ALL: %s\n",setlocale(LC_ALL, NULL)); + #endif + } + /* reset LC_TIME for strftime */ + if (strcmp(setlocale(LC_TIME,nullptr), "C") != 0) { + #ifdef DEBUG_LOCALE + printf("Resetting LC_TIME\n"); + #endif + setlocale(LC_TIME,"C"); + #ifdef DEBUG_LOCALE + printf("LC_ALL: %s\n",setlocale(LC_ALL, NULL)); + #endif + } + + (void) new gpsbabel::UsAsciiCodec(); /* make sure a US-ASCII codec is available */ + + global_opts.objective = wptdata; + global_opts.masked_objective = NOTHINGMASK; /* this makes the default mask behaviour slightly different */ + global_opts.charset_name.clear(); + global_opts.inifile = nullptr; + + gpsbabel_now = time(nullptr); /* gpsbabel startup-time */ + gpsbabel_time = current_time().toTime_t(); /* same like gpsbabel_now, but freezed to zero during testo */ + + if (gpsbabel_time != 0) { /* within testo ? */ + global_opts.inifile = inifile_init(QString(), MYNAME); + } + + init_vecs(); + init_filter_vecs(); + cet_register(); + session_init(); + waypt_init(); + route_init(); + + rc = run(prog_name); + cet_deregister(); waypt_flush_all(); - route_flush_all(); + route_deinit(); session_exit(); exit_vecs(); exit_filter_vecs();